public class demon3 {
    private static Object object1=new Object();
    private static Object object2=new Object();
    //创建一个死锁
    public static void main(String[] args) {
        Thread thread1=new Thread(()->{
           synchronized(object1){
               try {
                   Thread.sleep(100);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               synchronized (object2){
                   System.out.println("线程一");
               }
           }
        });
        Thread thread=new Thread(()->{
            synchronized(object2){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (object1){
                    System.out.println("线程 二");
                }
            }
        });
        thread.start();
        thread1.start();
    }
}
